import Ember from 'ember';
import config from '../config/environment';

export default DS.JSONAPIAdapter.extend({
  curStatus: Ember.inject.service('current-status'),
  ajaxCall: Ember.inject.service('ajax-call'),
  host: config.host + '/api',
  //suffix: '.json',
  suffix: '',
  namespace: '',
  pathForType: function(type) {
    // console.log("host iss:" + this.host);
    // console.log("pathForType in:" + type + " and camelize:" + Ember.String.camelize(type));
    return Ember.String.camelize(type) + this.get('suffix');
  },
  headers: Ember.computed('curStatus.curStatus.currentUser','ajaxCall.action', function() {
    var header = {
      //统一设置token
      'ccd-token': this.get('curStatus.curStatus.currentUser.token'),
      'ccd-user-id': this.get('curStatus.curStatus.currentUser.id'),
      'tenantId': 111,
      'action':   this.get("ajaxCall").get("action")
    };
    console.log("headers is:",header);
    //请求后需要把action置空,
    this.get("ajaxCall").set("action",null);
    return header;
  })
});
